<template>
  <div class="DiscoveryDetails" v-if="discoverydetails">
    <div class="card" v-if="discoverydetails.list != ''">
      <h1 v-if="discoverydetails.total">
        共<span>{{ discoverydetails.total }}</span
        >部作品
      </h1>
      <li v-for="item in discoverydetails.list" :key="item.id">
        <div
          class="left"
          @click="
            $router.push({
              path: '/classify',
              query: { id: item.id },
            })
          "
        >
          <img :src="item.cover" alt="" />
          <span>{{Math.floor(item.duration/60)>=10?Math.floor(item.duration/60):"0"+Math.floor(item.duration/60)}}'{{item.duration%60>=10?item.duration%60:"0"+item.duration%60}}"</span>
        </div>
        <div class="right">
          <h2>{{ item.title }}</h2>
          <span>播放量{{ item.count.count_view | parsePlayCount }}</span
          ><span>喜欢{{ item.count.count_like | parsePlayCount }}</span>
          <div class="tx" @click="
          $router.push({
            path: '/creatordetails',
            query: { id: item.author.userinfo.id },
          })
        ">
            <img :src="item.author.userinfo.avatar" alt="" />
            <p>{{ item.author.userinfo.username }}</p>
          </div>
        </div>
      </li>
    </div>
    <div class="none" v-else>
      <img src="../assets/001.jpg" alt="" />
      <span>没有搜索到作品</span>
    </div>
  </div>
</template>

<script>
export default {
  props: ["SearchValue","discoverydetails"],
  filters: {
    parsePlayCount: function (e) {
      if (e >= 10000) {
        return (e / 10000).toFixed(1) + "w";
      } else if (e >= 1000) {
        return (e / 1000).toFixed(1) + "k";
      } else {
        return e;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.DiscoveryDetails {
  .card {
    h1 {
      font-size: 12px;
      color: grey;
      margin: 10px;
      span {
        color: red;
      }
    }
    li {
      list-style: none;
      margin: 10px;
      display: flex;
      padding-bottom: 20px;
      border-bottom: 1px solid gray;

      .left {
        flex-shrink: 0;
        width: 50%;
        height: 100px;
        position: relative;
        img {
          width: 100%;
          height: 100%;
          display: block;
          border-radius: 5px;
          border: 1px solid #d0d0d0;
        }
        span{
          position: absolute;
          bottom: 4px;
          right: 8px;
          color: white;
          font-size: 12px;
          text-shadow: 0 0 2px black;
        }
      }
      .right {
        h2 {
          font-weight: bold;
          font-size: 14px;
          margin: 10px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          overflow: hidden;
        }
        span {
          font-size: 12px;
          color: grey;
          margin-left: 10px;
        }
        .tx {
          display: flex;

          img {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            margin: 10px;
          }
          p {
            font-size: 12px;
            color: grey;
            margin: 10px 0;
          }
        }
      }
    }
  }
  .none {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    span {
      color: gray;
    }
  }
}
</style>